package com.lilicould.controller;

import com.lilicould.service.impl.RepairServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/repair/accept")
public class RepairAcceptController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String employeeId = req.getParameter("employeeId");
        String requestId = req.getParameter("requestId");
        RepairServiceImpl repairService = new RepairServiceImpl();
        boolean result = repairService.updateRepairEmployeeId(requestId, employeeId);
        if (result) {
            req.getRequestDispatcher("/employee/personalInfo").forward(req, resp);
        } else {
            req.setAttribute("error", "插入失败");
            req.getRequestDispatcher("/page/err.jsp").forward(req, resp);
        }
    }
}
